var moment = require('moment');
var mongoose = require('mongoose');
var Schema = mongoose.Schema;
var Common = require('../util/common');

var Article = new Schema({
  author: {
    type: Schema.Types.ObjectId,
    ref: "User"
  },

  title: {
    type: String,
    default: ''
  },

  html: {
    type: String,
    default: ''
  },

  markdown: {
    type: String,
    default: ''
  },

  tags: [String],

  created: {
    type: Date,
    default: moment().utc().format()
  },

  lastmod: {
    type: Date,
    default: moment().utc().format()
  },
});

Article.pre("save", function(next) {
  this.lastmod = moment().utc().format();
  next();
});

exports.Article = mongoose.model("Article", Article);
